package string.test;

import org.junit.Test;

public class StringConcactAdd {
	
	@Test
	public void test() {
		//速度 append > concat >> + ，+最慢
		String s1 = new String("");
		String s2 = new String("");
		StringBuilder s3= new StringBuilder("");
		
		long l1 = System.currentTimeMillis();
		for(int i=0;i<100000;i++) {
			s1 += "1";
		}
		long l2 = System.currentTimeMillis();
		System.out.println(l2-l1);
		
		long l3 = System.currentTimeMillis();
		for(int i=0;i<100000;i++) {
			s2.concat("1");
		}
		long l4 = System.currentTimeMillis();
		System.out.println(l4-l3);
		
		long l5 = System.currentTimeMillis();
		for(int i=0;i<100000;i++) {
			s3.append("1");
		}
		long l6 = System.currentTimeMillis();
		System.out.println(l6-l5);
		
	}
}
